<?php
header('Content-Type: text/plain');
try {
    $redis = new Redis();
    $connected = $redis->connect('127.0.0.1', 6379, 1);
    if (!$connected) throw new Exception("连接失败");
    
    echo "连接成功！\n";
    echo "PING响应: " . $redis->ping() . "\n";
    
    // 测试写入数据
    $redis->set('test_key', 'hello_redis', 10);
    echo "读取数据: " . $redis->get('test_key') . "\n";
    
} catch (Exception $e) {
    echo "错误: " . $e->getMessage();
}